<?php namespace system\model;
use houdunwang\model\Model;
class Lunbo extends Model{
	//数据表
	protected $table = "lunbo";

	//允许填充字段
	protected $allowFill = ['*' ];

	//禁止填充字段
	protected $denyFill = [ ];

	//自动验证
	protected $validate=[
		//['字段名','验证方法','提示信息',验证条件,验证时间]
	];

	//自动完成
	protected $auto=[
		//['字段名','处理方法','方法类型',验证条件,验证时机]
	];

	//自动过滤
    protected $filter=[
        //[表单字段名,过滤条件,处理时间]
    ];

	//时间操作,需要表中存在created_at,updated_at字段
	protected $timestamps=false;
     public function lunboadd(){
//		 p($_POST);die;
		 if(empty($_POST['lb_url']) && empty($_POST['lb_img'])){
            message('图片url或者图片不能为空','back','error');
		 }
		 $file=$_POST['lb_img'];
		 $outFile=$_POST['lb_img'];
		 $thumbWidth=690;
		 $thumbHeight=335;
		 $thunbType=6;
		 Image::thumb($file, $outFile, $thumbWidth, $thumbHeight, $thunbType);
		 $res=Db::table('lunbo')->insert(['lb_url'=>$_POST['lb_url'],'lb_img'=>$_POST['lb_img']]);
		 return 1;
	 }
	//轮播图编辑提交
	  public  function  lunboedit($lbid){
		  if(empty($_POST['lb_url']) && empty($_POST['lb_img'])){
			  message('图片url或者图片不能为空','back','error');
		  }
//		  p($_POST);die;
		  return Db::table('lunbo')->where("lbid",$lbid)->update(['lb_url'=>$_POST['lb_url'],'lb_img'=>$_POST['lb_img']]);
	  }
     //找出轮播图数据
	public function getdata(){
		return $this->get()->toArray();
	}


}